<extend name="Public/base"/>
<block name="content">
<h3>插件管理</h3>
<div class="panel panel-default">
	<div class="panel-heading">插件配置 [ <{$data.title}> ]</div>
 		<div class="panel-body">
				<form action="<{:U('saveConfig')}>" class="form-horizontal" method="post">
					<empty name="custom_config">
						<foreach name="data['config']" item="form" key="o_key">
						<div class="form-group">
							<label class="col-sm-2 control-label">
							<{$form.title|default=''}>
							</label>
							<switch name="form.type">
								<case value="num">
								<div class="col-sm-1">
									<input type="text" class="form-control" name="config[<{$o_key}>]"  value="<{$form.value}>">
								</div>
								</case>
								<case value="text">
								<div class="col-sm-2">
									<input type="text" class="form-control" name="config[<{$o_key}>]"  value="<{$form.value}>">
								</div>
								</case>
								<case value="long_text">
								<div class="col-sm-5">
									<input type="text" class="form-control" name="config[<{$o_key}>]"  value="<{$form.value}>">
								</div>
								</case>
								<case value="password">
								<div class="col-sm-2">
									<input type="password" name="config[<{$o_key}>]" class="form-control" value="<{$form.value}>">
								</div>
								</case>
								<case value="hidden">
									<input type="hidden" name="config[<{$o_key}>]" value="<{$form.value}>">
								</case>
								<case value="radio">
								<div class="col-sm-3">
								<foreach name="form.options" item="opt" key="opt_k">
									<label class="radio pull-left mr">
										<input type="radio" name="config[<{$o_key}>]" value="<{$opt_k}>" <eq name="form.value" value="$opt_k"> checked</eq>><{$opt}>
									</label>
								</foreach>
								</div>
								</case>
								<case value="checkbox">
								<div class="col-sm-2">
									<foreach name="form.options" item="opt" key="opt_k">
										<label class="checkbox mr pull-left" style="width:auto;">
											<php>
												is_null($form["value"]) && $form["value"] = array();
											</php>
											<input type="checkbox" name="config[<{$o_key}>][]" value="<{$opt_k}>" <in name="opt_k" value="$form.value"> checked</in>><{$opt}>
										</label>
									</foreach>
								</div>
								</case>
								<case value="select">
								<div class="col-sm-2">
									<select name="config[<{$o_key}>]" class="form-control">
										<foreach name="form.options" item="opt" key="opt_k">
											<option value="<{$opt_k}>" <eq name="form.value" value="$opt_k"> selected</eq>><{$opt}></option>
										</foreach>
									</select>
								</div>
								</case>
								<case value="textarea">
								<div class="col-sm-4">									
									<textarea name="config[<{$o_key}>]" class="form-control"><{$form.value}></textarea>									
								</div>
								</case>

								<case value="group">
									<ul class="nav nav-pills"style="margin-bottom:15px">
										<volist name="form.options" id="li">
											<li data-tab="tab<{$i}>" <eq name="i" value="1">class="active"</eq>><a href="#tab<{$i}>" data-toggle="tab"><{$li.title}></a></li>
										</volist>
							    	</ul>
							    	<div class="tab-content">
							    	<volist name="form.options" id="tab">
							    		<div id="tab<{$i}>" class="tab-pane fade <eq name="i" value="1">in active</eq>">
							    		<foreach name="tab['options']" item="tab_form" key="o_tab_key">
							    		<div class="form-group">
							    			<label class="col-sm-2 control-label">
												<{$tab_form.title|default=''}>
											</label>							    			
							    				<switch name="tab_form.type">
													<case value="num">
													<div class="col-sm-1">
														<input type="text" name="config[<{$o_tab_key}>]" class="form-control" value="<{$tab_form.value}>">
													</div>
													</case>
													<case value="text">
													<div class="col-sm-2">
														<input type="text" name="config[<{$o_tab_key}>]" class="form-control" value="<{$tab_form.value}>">
													</div>
													</case>
													<case value="long_text">
													<div class="col-sm-5">
														<input type="text" name="config[<{$o_tab_key}>]" class="form-control" value="<{$tab_form.value}>">
													</div>
													</case>
													<case value="password">
													<div class="col-sm-2">
														<input type="password" name="config[<{$o_tab_key}>]" class="form-control" value="<{$tab_form.value}>">
													</case>
													<case value="hidden">
														
														<input type="hidden" name="config[<{$o_tab_key}>]" value="<{$tab_form.value}>">
													</case>
													<case value="radio">
													<div class="col-sm-3">
														<foreach name="tab_form.options" item="opt" key="opt_k">
															<label class="radio">
																<input type="radio" name="config[<{$o_tab_key}>]" value="<{$opt_k}>" <eq name="tab_form.value" value="$opt_k"> checked</eq>><{$opt}>
															</label>
														</foreach>
													</div>
													</case>
													<case value="checkbox">
													<div class="col-sm-3">
														<foreach name="tab_form.options" item="opt" key="opt_k">
															<label class="checkbox">
																<php> is_null($tab_form["value"]) && $tab_form["value"] = array();</php>
            													<input type="checkbox" name="config[<{$o_tab_key}>][]" value="<{$opt_k}>" <in name="opt_k" value="$tab_form.value"> checked</in>><{$opt}>
        													</label>
														</foreach>
													</div>
													</case>
													<case value="select">
													<div class="col-sm-3">
														<select name="config[<{$o_tab_key}>]" class="form-control">
															<foreach name="tab_form.options" item="opt" key="opt_k">
																<option value="<{$opt_k}>" <eq name="tab_form.value" value="$opt_k"> selected</eq>><{$opt}></option>
															</foreach>
														</select>
													</div>
													</case>
													<case value="textarea">	
													<div class="col-sm-5">													
														<textarea name="config[<{$o_tab_key}>]"><{$tab_form.value}></textarea>														
													</div>
													</case>
												</switch>
												<present name="tab_form.tip">
													<p class="help-block"><{$tab_form.tip}></sp>
												</present>
											</div>
							    			</foreach>
							    		</div>
							    	</volist>
							    	</div>
									</case>
								</switch>
								<present name="form.tip">
								<span class="check-tips"><{$form.tip}></span>
								</present>
							</div>
						</foreach>
						<else />
					<present name="custom_config">
						<{$custom_config}>
					</present>
					</empty>
					<div class="form-group">
						<div class="col-sm-4 col-sm-offset-2">
							<input type="hidden" name="id" value="<{:I('id')}>" readonly>
							<button type="submit" class="btn btn-success ajax-post" target-form="form-horizontal">确 定</button>
							<button class="btn btn-default" onclick="javascript:history.back(-1);return false;">返 回</button>
						</div>
					</div>
			</form>					
	</div>
</div>
</block>

<block name="script">
<script type="text/javascript" charset="utf-8">
	//导航高亮
    highlight_subnav("<{:U('Addons/index')}>");
    if($('ul.tab-nav').length){
    	//当有tab时，返回按钮不显示
    	$('.btn-return').hide();
    }

</script>
</block>
